<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>设备类型管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		function cheackAll(obj){
			var isCheck = $(obj).is(":checked");

			$("#contentTable").find("input[type='checkbox']").each(function(){
				$(this).prop("checked", isCheck);
			});
		}
		function batchProcesst(flag){
			var msg = "";
			if (flag == 'pass') { msg = "<spring:message code='tips.allpass' />" }
			else if (flag == 'reject') { msg = "<spring:message code='tips.alldismissal' />" }
			else{ msg = "<spring:message code='tips.delall' />" }

            confirmx(msg, function () {
                var groupList = "";
                $("#contentTable").find("input[type='checkbox']").each(function () {
                    if ($(this).prop('checked')) {
                        var egId = $(this).attr("id");
                        if(egId != "all")
                        {                        
                        	groupList = groupList + "'" + egId + "',";
                        }
                    }
                });
                $.ajax({
                    type: "POST",
                    url: "${ctx}/equipment/eleEquipmentType/checkEquipmentType",
                    data: {typeList: groupList, flag: flag},
                    datatype: "json",
                    success: function (data) {
                        alertx(data.msg, function () {
                            window.location.reload();
                        });
                    },
                    error: function (e) {
                        alertx("<spring:message code='tips.contactadmin' />");
                        console.log(e);
                    }
                });
            });
		};
		function resubmit(){
			var currentSelect = $("#delFlag").val();
			if(currentSelect != 3){
				 alertx("<spring:message code='tips.dismissal' />");
				 return;
				}
			
			var groupList = "";
            $("#contentTable").find("input[type='checkbox']").each(function () {
                if ($(this).prop('checked')) {
                    var egId = $(this).attr("id");
                    groupList = groupList + "'" + egId + "',";
                }
            });
            $.ajax({
                type: "POST",
                url: "${ctx}/equipment/eleEquipmentType/resubmit",
                data: {typeList: groupList},
                datatype: "json",
                success: function (data) {
                    alertx(data.msg, function () {
                        window.location.reload();
                    });
                },
                error: function (e) {
                    alertx("<spring:message code='tips.contactadmin' />");
                    console.log(e);
                }
            });
		};
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active">
			<a href="${ctx}/equipment/eleEquipmentType/">
				<spring:message code="menu.device.Equipment_Type_List"/>
			</a>
		</li>
		<shiro:hasPermission name="equipment:eleEquipmentType:edit">
			<li>
				<a href="${ctx}/equipment/eleEquipmentType/form">
					<spring:message code="menu.device.Equipment_Type_Add"/>
				</a>
			</li>
		</shiro:hasPermission>
	</ul>
		<div class="control-group" style="margin-bottom:20px;/*background-color:#f5f5f5;*/" >
		<input type="button" value="<spring:message code='Batch.deletion'/>" class="btn btn-default btn-lg" onclick="batchProcesst('delete');">
		
	<form:form id="searchForm" modelAttribute="eleEquipmentType" action="${ctx}/equipment/eleEquipmentType/" method="post"
			   class="breadcrumb form-search" style="float:right;padding-bottom:0px;padding-top:0px;">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label><spring:message code="common.dname"/>：</label>
				<form:input path="name" htmlEscape="false" maxlength="200" class="input-medium"/>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="<spring:message code='common.Query'/>"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	</div>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
			<th style="width:40px;text-align:center;"><input type="checkbox" onclick="cheackAll(this);" id="all"/></th>
				<th><spring:message code="common.dname"/></th>
				<th><spring:message code='common.resolution'/></th>
				<th><spring:message code="device.orientation"/></th>
				<th><spring:message code='menu.device.Equipment_Type'/></th>
				<th><spring:message code='common.update_time'/></th>

				<shiro:hasPermission name="equipment:eleEquipmentType:edit"><th><spring:message code='common.operation'/></th></shiro:hasPermission>
				<th><spring:message code='common.remarks'/></th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="eleEquipmentType">
			<tr>
				<td style="text-align:center;">
						<input type="checkbox" id="${eleEquipmentType.id}"/>
				</td>
				<td><a href="${ctx}/equipment/eleEquipmentType/form?id=${eleEquipmentType.id}">
					${eleEquipmentType.name}
				</a></td>
				
				<td>
					${eleEquipmentType.width} X ${eleEquipmentType.height}
				</td>
				<td>
					${fns:getDictLabel(eleEquipmentType.orientation, "orientation" ,"竖屏")}
				</td>
				<td>
					${eleEquipmentType.model}
				</td>

				<td>
					<fmt:formatDate value="${eleEquipmentType.updateDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>

				<shiro:hasPermission name="equipment:eleEquipmentType:edit"><td>
    				<a href="${ctx}/equipment/eleEquipmentType/form?id=${eleEquipmentType.id}"><spring:message code="common.modify"/></a>
					<a href="${ctx}/equipment/eleMonitorParam/list?equipmentId=${eleEquipmentType.id}"><spring:message code="common.setting"/></a>					
					<a href="${ctx}/equipment/eleEquipmentType/delete?id=${eleEquipmentType.id}"
					   onclick="return confirmx('<spring:message code="tips.deleteconfirm"/>', this.href)">
						<spring:message code='common.delete'/>
					</a>
				</td></shiro:hasPermission>
				<td>
						${eleEquipmentType.remarks}
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>